import codecs


text = u"hello, 胡鑫"

print(text)

with codecs.open("output.txt", 'w', encoding="utf-8") as file:
    file.write(text)